<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->

<title>getch</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_002_001_412">&nbsp;</a>NAME</h4><blockquote>
getch, wgetch, mvgetch, mvwgetch - get a single-byte character from the
terminal
</blockquote><h4><a name = "tag_002_001_413">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="curses.h.html">curses.h</a>&gt;

int getch(void);

int mvgetch(int <i>y</i>, int <i>x</i>);

int mvwgetch(WINDOW *<i>win</i>, int <i>y</i>, int <i>x</i>);

int wgetch(WINDOW *<i>win</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_002_001_414">&nbsp;</a>DESCRIPTION</h4><blockquote>
These functions read a single-byte character from the terminal associated with
the current or specified window.  The results are unspecified if the input
is not a single-byte character.  If
<i><a href="keypad.html">keypad()</a></i>
is enabled, these functions respond to the pressing of a function key by
returning the corresponding KEY_ value defined in
<i><a href="curses.h.html">&lt;curses.h&gt;</a></i>.
<p>
Processing of terminal input is subject to the general rules described in
<xref href=terminalinput><a href="intov.html#tag_001_005">
Input Processing
</a></xref>.
<p>
If echoing is enabled, then the character is echoed as though it were
provided as an input argument to
<i><a href="addch.html">addch()</a></i>,
except for the following characters:
<p><table  align=center><tr valign=top><th align=left><i> &lt;backspace&gt;, &lt;left-arrow&gt; and the current erase character: </i>
<th align=left><i> The input is interpreted as specified in and then the character at the resulting cursor position is deleted as though were called, except that if the cursor was originally in the first column of the line, then the user is alerted as though were called. </i>
<tr valign=top><td align=left><i>Function keys</i>
<td align=left><i> The user is alerted as though were called.  Information concerning the function keys is not returned to the caller. </i>
</table>
<p>
If the current or specified window is not a pad, and it has been moved or
modified since the last refresh operation, then it will be refreshed before
another character is read.
</blockquote><h4><a name = "tag_002_001_415">&nbsp;</a>RETURN VALUE</h4><blockquote>
Upon successful completion
<i>getch()</i>,
<i>mvgetch()</i>,
<i>mvwgetch()</i>
and
<i>wgetch()</i>
return the single-byte character, KEY_ value, or ERR.
When in the nodelay mode and no data is available, ERR is returned.
</blockquote><h4><a name = "tag_002_001_416">&nbsp;</a>ERRORS</h4><blockquote>
No errors are defined.
</blockquote><h4><a name = "tag_002_001_417">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
Applications should not define the escape key by itself as a single-character
function.
<p>
When using these functions, nocbreak mode (.Fn nocbreak )
and echo mode (.Fn echo )
should not be used at the same time.  Depending on the state of the terminal
when each character is typed, the program may produce undesirable results.
</blockquote><h4><a name = "tag_002_001_418">&nbsp;</a>SEE ALSO</h4><blockquote>
<xref href=terminalinput><a href="intov.html#tag_001_005">
Input Processing
</a></xref>,
<i><a href="cbreak.html">cbreak()</a></i>,
<i><a href="doupdate.html">doupdate()</a></i>,
<i><a href="insch.html">insch()</a></i>,
<i><a href="curses.h.html">&lt;curses.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
